<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfCategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('category', function (Blueprint $table) {
            $table->id();
            $table->string("name",20)->comment("分类名称");
            $table->string("desc",50)->comment("分类描述");
            $table->string("imageUrl",100)->comment("分类图片");
            $table->unsignedInteger("sort")->default(0)->comment("排序 越小越靠前");
            $table->tinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除，1：已删除");
            $table->integer("createdAt")->comment("创建时间");
            $table->integer("updatedAt")->comment("修改时间");
            $table->index("createdAt","idx_created_at");
            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX','');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}category` COMMENT = '菜品分类表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('kf_category');
    }
}
